#!/bin/bash


name="go.main_linux"
# arch="arm64"

build(){
    local arch=$1
    echo "[i] build $arch"
    CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -o "${name}_$arch" ./*.go
}

job(){
    build "amd64"
    build "arm64"
}
if job;then
    echo "[i] build ok"
else
    echo "[E] build error"
    exit 1
fi
# CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o main_linux_arm64 *.go
# CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main_linux_amd64 *.go


ls -alFh --color ./"${name}"*

cat <<EOF
scp "${name}_arm64" hbl@server22.lan:/tmp/
scp "${name}_amd64" hbl@server.lan:/tmp/
EOF

scp "${name}_arm64" hbl@server22.lan:/tmp/
scp "${name}_amd64" hbl@server.lan:/tmp/

